﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIS.SDK.Api.Response;
using AIS.SDK.Common;
using AIS.SDK.Model;
using Newtonsoft.Json;

namespace AIS.SDK.Api.Requests
{
    public class ValidateTokenV2 : ApiRequest<ValidateTokenResponse>
    {
        public ValidateTokenV2(AppIdentication _token)
        {
            AppIdentity = _token;
        }

        public AppIdentication AppIdentity { get; set; }




        internal override string Method
        {
            get { return "POST"; }
        }

        protected override string UrlFormat
        {
            get { return "/validatetoken"; }
        }

        internal override string GetUrl()
        {
            return GlobalVariables.GetAISServerUrl() + UrlFormat;
        }

        protected override bool NeedToken
        {
            get { return false; }
        }

        internal override void Validate()
        {
            if (AppIdentity == null || String.IsNullOrWhiteSpace(AppIdentity.token))
            {
                throw new ArgumentNullException("Invalid Token");
            }
        }

        public override string GetPostContent()
        {
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Ignore

            };
            return JsonConvert.SerializeObject(AppIdentity, settings);
        }

        
    }
}
